package com.junchao.peng.service.impl;

import com.junchao.peng.mapper.MessageMapper;
import com.junchao.peng.pojo.Message;
import com.junchao.peng.service.MessageService;
import com.junchao.peng.utils.JsonResult;
import org.springframework.stereotype.Service;

/**
 * @author dell
 */
@Service("MessageService")
public class MessageServiceImpl implements MessageService {

    final MessageMapper messageMapper;

    public MessageServiceImpl(MessageMapper messageMapper) {
        this.messageMapper = messageMapper;
    }

    @Override
    public JsonResult listMessage() {
        return new JsonResult(messageMapper.listMessage());
    }

    @Override
    public JsonResult selectMessageById(Integer id) {
        return new JsonResult(messageMapper.selectMessageById(id));
    }

    @Override
    public JsonResult insertMessage(Message message) {
        if (messageMapper.insertMessage(message)) {
            return new JsonResult("插入成功");
        }
        return new JsonResult("插入失败",500);
    }
}
